Mule : Joram Integration
This page last changed on Jul 19, 2005 by aperepel.
Using Joram with Mule is a little less straight forward that the other Jms servers if you do not have a Jndi context set up for your connections and destinations. If you have Jndi set up you can use the following- <connector name="JMSConnector" className="org.mule.providers.jms.JmsConnector"> <properties> <property name="connectionFactoryJndiName" value="QueueConnectionFactory"/> <property name="specification" value="1.1"/> <property name="jndiDestinations" value="true"/> <property name="connectionFactoryJndiName" value="ConnectionFactory"/> <property name="jndiInitialFactory" value="fr.dyade.aaa.jndi2.client.NamingContextFactory"/> <map name="jndiProviderProperties"> <property name="java.naming.factory.host" value="localhost"/> <property name="java.naming.factory.port" value="16400"/> </map> </properties> </connector>
If you do not have Jndi set up you need to manually create a Jndi Initial Context. You can do this by adding a Mule property factory (like the one listed below). Your configuration will look something like - <connector name="JMSConnector" className="org.mule.providers.jms.JmsConnector"> <properties> <property name="connectionFactoryJndiName" value="QueueConnectionFactory"/> <property name="specification" value="1.1"/> <property name="jndiDestinations" value="true"/> <list name="jndiQueues"> <entry value="exception.queue"/> </list> <property-factory name="jndiContext" value="com.foo.joram.JoramInitialContextFactory"/> </properties> </connector> The Jndi property factory class will look like the following, though you may want to add support for other Joram properties. JoramInitialContextFactory.java public class JoramTest implements PropertyFactory { public Object create(Map properties) throws Exception { String connectionFactoryJndiName = (String) properties.get("connectionFactoryJndiName"); if (connectionFactoryJndiName == null) { throw new InitialisationException( "connectionFactoryJndiName must be set"); } // Connecting to JORAM server: AdminModule.connect("root", "root", 60); //Create anonymous user if security is not required User user = User.create("anonymous", "anonymous"); // Creating the JMS administered objects: javax.jms.ConnectionFactory connFactory = TcpConnectionFactory.create(); // Binding objects in JNDI: //Create Jndi Queues javax.naming.Context jndiCtx = new javax.naming.InitialContext(); jndiCtx.bind(connectionFactoryJndiName, connFactory); List queues = (List)properties.get("jndiQueues"); if(queues!=null) { Queue queue; String name; for (Iterator iterator = queues.iterator(); iterator.hasNext();) { name = (String) iterator.next(); queue = (Queue) Queue.create(0); // Setting free access to the queue: queue.setFreeReading(); queue.setFreeWriting(); jndiCtx.bind(name, queue); } } //Create Jndi Topics List topics = (List)properties.get("jndiTopics"); if(topics!=null) { Topic topic; String name; for (Iterator iterator = topics.iterator(); iterator.hasNext();) { name = (String) iterator.next(); topic = (Topic) Topic.create(0); // Setting free access to the queue: topic.setFreeReading(); topic.setFreeWriting(); jndiCtx.bind(name, topic); } } AdminModule.disconnect(); return jndiCtx; } } |
Document generated by Confluence on Nov 27, 2006 10:27 |